﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WEB.APP._Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Criteria Based Project Allocation System </title>
    <link href="css/toolbar.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        document.onkeydown = function() {
            if (window.event && window.event.keyCode == 116) {
                window.event.keyCode = 505;
            }

            if (window.event && window.event.keyCode == 505) {
                return false;
            }
        }
        
        function showPrinterWindow(url) {
            httpUrlReport.setValue(url);
            wndPrintReport.load({ url: httpUrlReport.getValue() });
            wndPrintReport.show();
        }

    </script>

    <script type="text/javascript">
        function DocumentReady() {
            MethodNamespace.DocumentReady({
                success: function() {
                    AddAbout();
                }
            });
        }
        function CategorySelect(el, record, index) {
            stProduct.reload();
            cboProduct.setValue(0);
        }
        function LoadScreen(el) {
            if (treeNavigator.root.childNodes.length === 0 && treeNavigator.root.text !== 'Desktop')
                return;

            treeNavigator.root.setText(el.text);
            treeNavigator.root.removeChildren();
            MethodNamespace.LoadScreen(el.stateId, el.text);
        }
        function logout() {
            window.location.href = 'Logout.aspx';
        }

        function LoadTab(el) {
            LoadTabPanel(el.id.replace("mi", ""), '');
        }


        function LoadTabPanel(screenId, id) {
            var record = stScreen.getById(screenId);
            txttreeId.value = screenId;
            if (typeof record === "undefined") {
                return;
            }
            record = record.data;
            var url = "";
            if (id !== '') {
                url = String.Format("{0}/Modules/{1}/{2}.{3}?id={4}", record.HostName, record.Module, record.FileName, record.Extention, id);
            }
            else {
                url = String.Format("{0}/Modules/{1}/{2}.{3}", record.HostName, record.Module, record.FileName, record.Extention);
            }
            var title = record.ScreenName;
            addTab(pnlMain, record.ScreenId + id, title, url);
        }
        function addTab(tabPanel, id, title, url) {
            var tab = tabPanel.getComponent(id);

            if (!tab) {
                tab = tabPanel.add({
                    id: id,
                    title: title,
                    closable: true,
                    autoLoad: {
                        showMask: true,
                        url: url,
                        mode: "iframe",
                        maskMsg: "Loading " + title + "..."
                    }
                });

                tab.on("activate", function() {
                    //var item = MenuPanel1.menu.items.get(id + "_item");
                    //if (item) {
                    //  MenuPanel1.setSelection(item);
                    //}
                }, this);
            }

            tabPanel.setActiveTab(tab);
        }

        function AddAbout() {
            addTab(pnlMain, 'SYS0000', 'About', '\About.aspx');
        }

        function pnlMainBeforeTabChange(tabPanel, tab) {
            if (tab !== undefined && tab.id === 'SYS0000' && tab.layout !== "fit") {
                window.frames[tab.iframe.id].location.reload(true);
            }
        }

        var favTree = function(tree) {
            var id = treeNavigator.selModel.selNode.id;
            if (id !== "") {
                MethodNamespace.favScreen(id);
            }

        }

        function loadDesktop() {
            if (treeNavigator.root.childNodes.length === 0)
                return;
            treeNavigator.root.setText('Desktop');
            treeNavigator.root.removeChildren();
            MethodNamespace.LoadTreeFromDesktop();
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:Hidden ID="txttreeId" Text="" runat="server" />
    <ext:Store runat="server" ID="stScreen">
        <Reader>
            <ext:JsonReader IDProperty="ScreenId">
                <Fields>
                    <ext:RecordField Name="ScreenId" />
                    <ext:RecordField Name="ScreenName" />
                    <ext:RecordField Name="HostName" />
                    <ext:RecordField Name="Module" />
                    <ext:RecordField Name="FileName" />
                    <ext:RecordField Name="Extention" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <ext:Panel ID="pnlLayout" runat="server" Region="Center">
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Content>
                            <div style="background-color: #25589D;padding:5px;color: White;font-family: Arial;">
                                <dib style="float: right;">
                                    <img height="50" src="https://myuwsauth.uws.edu.au/livery08/images/appslivery/logo-part.gif" />
                                </dib>
                                Bringing knowledge to life<br />
                                <span style="font-size: large;"><b>MyUWS Professional Experience: 300579</b></span>
                                <div style="clear:both;"></div>
                            </div>
                            <div style="background-color: #6597C7;padding:5px;color: White;font-family: Arial;margin: 0 -2 0 -2;">
                                <b>School of Computing and Mathematics</b><br />
                                College of Health and Science
                            </div>
                        </Content>
                        <Items>
                            <ext:ToolbarSpacer />
                            <ext:Label ID="Label1" runat="server" FieldLabel="<b>Criteria Based Project Allocation System</b>" LabelSeparator=" " />
                            <ext:ToolbarFill />
                            <ext:SplitButton ID="sButtonUser" runat="server" Icon="User">
                                <Menu>
                                    <ext:Menu ID="Menu4" runat="server">
                                        <Items>
                                            <ext:MenuItem Text="Change password" Icon="KeyAdd">
                                                <DirectEvents>
                                                    <Click OnEvent="menuChange_Click">
                                                    </Click>
                                                </DirectEvents>
                                            </ext:MenuItem>
                                        </Items>
                                    </ext:Menu>
                                </Menu>
                            </ext:SplitButton>
                            <ext:ToolbarSeparator />
                            <ext:Button ID="Button4" runat="server" Text="Logout" Icon="LockGo">
                                <Listeners>
                                    <Click Fn="logout" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarSeparator />
                            <ext:SplitButton ID="Button1" runat="server" Icon="Help">
                                <Menu>
                                    <ext:Menu ID="Menu1" runat="server">
                                        <Items>
                                            <ext:MenuItem Text="About" Icon="Information">
                                                <Listeners>
                                                    <Click Handler="AddAbout();" />
                                                </Listeners>
                                            </ext:MenuItem>
                                        </Items>
                                    </ext:Menu>
                                </Menu>
                            </ext:SplitButton>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:BorderLayout ID="BorderLayout1" runat="server">
                        <North>
                            <ext:Panel ID="Panel3" runat="server" BodyBorder="false">
                                <TopBar>
                                    <ext:Toolbar ID="tbModule" runat="server">
                                        <Items>
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>
                            </ext:Panel>
                        </North>
                        <West Collapsible="true" MinWidth="175" Split="true">
                            <ext:Panel ID="pnlNavigator" runat="server" Width="200" Title="CATALOGUE" Collapsed="false"
                                Layout="Fit" Margins="2 0 2 2">
                                <Items>
                                    <ext:TreePanel ID="treeNavigator" runat="server" BodyBorder="false" RootVisible="false"
                                        AutoScroll="true" NoLeafIcon="false">
                                        <Root>
                                            <ext:TreeNode NodeID="root" Text="Module" Expanded="true">
                                            </ext:TreeNode>
                                        </Root>
                                        <Listeners>
                                            <Click Handler="LoadTabPanel(node.id,'');
                                                            if(stScreen.getById(node.id) !== undefined){
                                                                MethodNamespace.checkStatus(node.id,{
                                                                    success: function(){
                                                                    }
                                                                });
                                                            }" />
                                        </Listeners>
                                    </ext:TreePanel>
                                </Items>
                            </ext:Panel>
                        </West>
                        <Center>
                            <ext:TabPanel ID="pnlMain" runat="server" EnableTabScroll="true" Margins="2 2 2 0">
                                <Items>
                                </Items>
                                <Plugins>
                                    <ext:TabCloseMenu ID="TabCloseMenu1" runat="server" CloseAllTabsText="Close All Tabs"
                                        CloseOtherTabsText="Close Other Tabs" CloseTabText="Close Tab">
                                        <CustomConfig />
                                    </ext:TabCloseMenu>
                                </Plugins>
                                <Listeners>
                                    <BeforeTabChange Fn="pnlMainBeforeTabChange" />
                                </Listeners>
                            </ext:TabPanel>
                        </Center>
                    </ext:BorderLayout>
                </Items>
                <BottomBar>
                    <ext:StatusBar ID="statusMain" runat="server" DefaultText="Server: ">
                    </ext:StatusBar>
                </BottomBar>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    <ext:Hidden ID="httpUrlReport" runat="server">
    </ext:Hidden>
    <ext:Window runat="server" ID="wndPrintReport" Cls="wndPrintReport" Title="In" Hidden="true"
        Layout="card" ActiveIndex="0" Modal="true" AutoScroll="false" Width="850" Height="635"
        Closable="true" Maximizable="true" Padding="0">
        <AutoLoad Mode="IFrame" ManuallyTriggered="true" DiscardUrl="true" NoCache="true"
            Method="GET" PassParentSize="true" />
    </ext:Window>
    <%--<script src="/Javascript/Report/Report.js" type="text/javascript"></script>--%>
    <ext:Window ID="winChangePass" runat="server" Title="Change Password" Frame="false"
        Hidden="true" CenterOnLoad="true" Width="400" Height="120" BodyStyle="padding:5px 0px 0px 20px;"
        Resizable="false" Closable="true" Layout="Fit" AutoHeight="true" Icon="Key" Modal="true">
        <Items>
            <ext:FormPanel ID="FormChangePass" runat="server" Header="false" LabelWidth="120"
                AutoHeight="true" Border="false" MonitorValid="true" BodyStyle="background-color:transparent;"
                Layout="FormLayout">
                <Items>
                    <ext:TextField ID="txtUserName" runat="server" FieldLabel="User Name" AnchorHorizontal="93%"
                        MsgTarget="Side" Disabled="true" />
                    <ext:TextField ID="txtOldPassword" runat="server" FieldLabel="Old Password"
                        InputType="Password" Anchor="93%" AllowBlank="false" MsgTarget="Side" />
                    <ext:TextField ID="txtPassword" runat="server" FieldLabel="New Password" InputType="Password"
                        Anchor="93%" AllowBlank="false" MsgTarget="Side">
                        <CustomConfig>
                            <ext:ConfigItem Name="initialPassField" Value="#{txtConfirmPassword}" Mode="Value" />
                        </CustomConfig>
                    </ext:TextField>
                    <ext:TextField ID="txtConfirmPassword" runat="server" FieldLabel="Retype Password" InputType="Password"
                        AnchorHorizontal="93%" Vtype="password" VtypeText="Passwords are not the same"
                        AllowBlank="false" BlankText="Can not be blank" MsgTarget="Side">
                        <CustomConfig>
                            <ext:ConfigItem Name="initialPassField" Value="#{txtPassword}" Mode="Value" />
                        </CustomConfig>
                    </ext:TextField>
                    <ext:Label ID="lblError" Text="" Hidden="true" IconAlign="Left" runat="server" />
                </Items>
                <Listeners>
                    <ClientValidation Handler="#{btnChange}.setDisabled(!valid);" />
                </Listeners>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button ID="btnChange" runat="server" Text="Save" Icon="Disk">
                <DirectEvents>
                    <Click OnEvent="btnChange_Click" />
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="btnCancel" runat="server" Text="Cancel" Icon="Cancel">
                <Listeners>
                    <Click Handler="#{winChangePass}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    </form>
</body>
</html>
